# mode is an optional string that specifies the mode in which the file
# is opened. It defaults to 'r' which means open for reading in text
# mode.  Other common values are 'w' for writing (truncating the file if
# it already exists), 'x' for creating and writing to a new file, and
# 'a' for appending (which on some Unix systems, means that all writes
# append to the end of the file regardless of the current seek position).
# In text mode, if encoding is not specified the encoding used is platform
# dependent: locale.getpreferredencoding(False) is called to get the
# current locale encoding. (For reading and writing raw bytes use binary
# mode and leave encoding unspecified.) The available modes are:
#
# ========= ===============================================================
# Character Meaning
# --------- ---------------------------------------------------------------
# 'r'       open for reading (default)
# 'w'       open for writing, truncating the file first
# 'x'       create a new file and open it for writing
# 'a'       open for writing, appending to the end of the file if it exists
# 'b'       binary mode
# 't'       text mode (default)
# '+'       open a disk file for updating (reading and writing)
# 'U'       universal newline mode (deprecated)
# ========= ===============================================================
#
# The default mode is 'rt' (open for reading text). For binary random
# access, the mode 'w+b' opens and truncates the file to 0 bytes, while
# 'r+b' opens the file without truncation. The 'x' mode implies 'w' and
# raises an `FileExistsError` if the file already exists.
#
# Python distinguishes between files opened in binary and text modes,
# even when the underlying operating system doesn't. Files opened in
# binary mode (appending 'b' to the mode argument) return contents as
# bytes objects without any decoding. In text mode (the default, or when
# 't' is appended to the mode argument), the contents of the file are
# returned as strings, the bytes having been first decoded using a
# platform-dependent encoding or using the specified encoding if given.
#
# 'U' mode is deprecated and will raise an exception in future versions
# of Python.  It has no effect in Python 3.  Use newline to control
# universal newlines mode.

# r-只读
# w-只写,文件存在则覆盖,文件不存在则创建
# b-以二进制的形式打开文件(可以用来操作非文本文件)
# rb二进制读, wb二进制写
